home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1996 February
/
EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso
/
earcd
/
util4
/
chunker.lha
/
Chunker
/
source
/
chunker.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-11-10
|
2KB
|
79 lines
/*************************************************************************
*
* Chunker
*
* Copyright ©1995 Lee Kindness and Evan Tuer
* cs2lk@scms.rgu.ac.uk
*
* chunker.c
*/
#include "chunker.h"
/*************************************************************************
* main() - DaDDDaaah!
*/
int main(int argc, char **argv)
{
long ret = 10;
/* init */
if( InitSystem() )
{
struct Args *args;
if( args = GetChunkerArgs(argc, argv) )
{
FILEt source;
/* Open input file */
if( source = mfopen(args->arg_Filename, FILEOPEN_READ) )
{
char *destname;
long num = 0;
FILEt dest = NULL;
if( (destname = BuildFName(args->arg_Basename, &num)) &&
(dest = mfopen(destname, FILEOPEN_WRITE)) )
{
register long n = 0;
register int c;
mprintf("%s\n", destname);
for( c = mfgetc(source);
c != EOF;
c = mfgetc(source), ++n)
{
if( n == args->arg_Size )
{
FreeFName(destname);
mfclose(dest);
destname = BuildFName(args->arg_Basename, &num);
mprintf("%s\n", destname);
dest = mfopen(destname, FILEOPEN_WRITE);
n = 0;
}
mfputc(c, dest);
}
}
FreeFName(destname);
mfclose(dest);
mfclose(source);
ret = 0;
} else
mprintf("Can't open %s\n", args->arg_Filename);
FreeChunkerArgs(args);
} /* else arg fail */
FreeSystem();
} else
mprintf("Usage:\n chunker <file> <basename> <size>\n");
return( ret );
}